#!/usr/bin/gnuplot

reset

#set style line 1 lt 2 lc rgb '#000000' lw 1 # black
#set style line 2 lt 1 lc rgb '#9400d3' lw 1 # purple
#set style line 3 lt 1 lc rgb '#ff4500' lw 1 # orange-1
#set style line 4 lt 1 lc rgb '#006400' lw 1 # green
#set style line 5 lt 1 lc rgb '#ffa500' lw 1 # yellow
#set style line 6 lt 1 lc rgb '#0000ff' lw 1 # blue
#set style line 7 lt 1 lc rgb '#800000' lw 1 # brown
#set style line 8 lt 1 lc rgb '#ff0000' lw 1 # orange-2

# color definitions
set border linewidth 1.5
set style line  1 lt 2 lc rgb '#000000' lw 1 # black

set style line  4 lt 1 lc rgb '#ffa500' lw 1 # green
set style line  6 lt 1 lc rgb '#0000ff' lw 1 # blue
set style line  8 lt 1 lc rgb '#ff0000' lw 1 # orange-2
set style line 10 lt 1 lc rgb '#9400d3' lw 1 # purple

set style line 11 lt 2 lc rgb '#000000' lw 1 # black

set ylabel "Height (m)"

b2 = b1 = 0
back(x) = (b2 = b1, b1 = x)
OOA(x) = (back(x), $0 > 0 ? (log(b2/b1)/log(2)) : 1/0)
const(x) = 2

#-------------------------------------------------------------------------------------

set terminal wxt 1 size 1100,400 enhanced dashed

set multiplot layout 1,3 title 'Poiseuille Flow'
set xlabel "Velocity (m/sec)"
set xrange [*:*]
set yrange [*:*]#0.0:0.01]

set key reverse inside left center

set title ' '
plot 'POST_UG.dat' index  3 using 2:1 w lines ls 11 lt 1 title 'Analytic', \
     'POST_UG.dat' index  0 every  1 using 3:1 w points ls  4 title '  8 mesh', \
     'POST_UG.dat' index  1 every  2 using 3:1 w points ls  6 title ' 16 mesh', \
     'POST_UG.dat' index  2 every  4 using 3:1 w points ls  8 title ' 32 mesh', \
     'POST_UG.dat' index  3 every  8 using 3:1 w points ls 10 title ' 64 mesh'

set xlabel "abs error (m/sec)"
set logscale x
set xrange [*:*]
set yrange [*:*]

set title ' '
plot 'POST_UG.dat' index  0 every  1 using 4:1 w points ls  4 notitle, \
     'POST_UG.dat' index  1 every  2 using 4:1 w points ls  6 notitle, \
     'POST_UG.dat' index  2 every  4 using 4:1 w points ls  8 notitle, \
     'POST_UG.dat' index  3 every  8 using 4:1 w points ls 10 notitle

set xlabel "Grid Size Measure"
set ylabel "Observed Order"
set logscale x
set xrange [1:10]
set yrange [1:3]

unset key
set key inside left top

set ytics

set title ' '
plot 'POST_UG_NORMS.dat' using 1:(OOA($2)) with linespoints ls 11 lt -1 pt 6 title 'Observed order', \
     'POST_UG_NORMS.dat' using 1:(const($2)) with line ls 11 lt 3 title 'Theoretical order'


unset logscale x
unset multiplot

#-------------------------------------------------------------------------------------

set terminal wxt 2 size 900,400 enhanced dashed

set multiplot layout 1,2 title 'Poiseuille Flow'
set xlabel "Length (m)"
set ylabel "Pressure (Pa)"
set xrange [*:*]
set yrange [*:*]

set key reverse inside left bottom

set title
plot 'POST_PG.dat' index  3 using 1:2 w lines ls 11 lt 1 title 'Analytic', \
     'POST_PG.dat' index  0 every  1 using 1:3 w points ls  4 title '  8 mesh', \
     'POST_PG.dat' index  1 every  2 using 1:3 w points ls  6 title ' 16 mesh', \
     'POST_PG.dat' index  2 every  4 using 1:3 w points ls  8 title ' 32 mesh', \
     'POST_PG.dat' index  3 every  8 using 1:3 w points ls 10 title ' 64 mesh'

set ylabel "abs errror (Pa)"
set xlabel "Length (m)"
set logscale y
set xrange [*:*]
set yrange [*:*]

set key reverse inside left top

set ytics

set title
plot 'POST_PG.dat' index 0 every  1 using 1:4 w points ls  4 title '   8 mesh', \
     'POST_PG.dat' index 1 every  2 using 1:4 w points ls  6 title '  16 mesh', \
     'POST_PG.dat' index 2 every  4 using 1:4 w points ls  8 title '  32 mesh', \
     'POST_PG.dat' index 3 every  8 using 1:4 w points ls 10 title '  64 mesh'

unset logscale x
unset multiplot
